package com.jingjiu.homeservicesbiz.controller;

import java.util.List;

import com.jingjiu.homeservicesapi.domain.RestaurantInfo;
import com.jingjiu.homeservicesbiz.service.IRestaurantInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 餐饮信息：记录餐厅及其食品信息Controller
 * 
 * @author ruoyi
 * @date 2025-04-16
 */
@Controller
@RequestMapping("restaurant/system/info")
public class RestaurantInfoController extends BaseController
{

    @Autowired
    private IRestaurantInfoService restaurantInfoService;

    /**
     * 查询餐饮信息：记录餐厅及其食品信息列表
     */
    @RequiresPermissions("system:info:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RestaurantInfo restaurantInfo)
    {
        startPage();
        List<RestaurantInfo> list = restaurantInfoService.selectRestaurantInfoList(restaurantInfo);
        return getDataTable(list);
    }

    /**
     * 导出餐饮信息：记录餐厅及其食品信息列表
     */
    @RequiresPermissions("system:info:export")
    @Log(title = "餐饮信息：记录餐厅及其食品信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(@RequestBody RestaurantInfo restaurantInfo)
    {
        List<RestaurantInfo> list = restaurantInfoService.selectRestaurantInfoList(restaurantInfo);
        ExcelUtil<RestaurantInfo> util = new ExcelUtil<RestaurantInfo>(RestaurantInfo.class);
        return util.exportExcel(list, "餐饮信息：记录餐厅及其食品信息数据");
    }


    /**
     * 新增保存餐饮信息：记录餐厅及其食品信息
     */
    @RequiresPermissions("system:info:add")
    @Log(title = "餐饮信息：记录餐厅及其食品信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(@RequestBody RestaurantInfo restaurantInfo)
    {
        return toAjax(restaurantInfoService.insertRestaurantInfo(restaurantInfo));
    }

    /**
     * 修改餐饮信息：记录餐厅及其食品信息
     */
    @RequiresPermissions("system:info:edit")
    @GetMapping("/get/{id}")
    public RestaurantInfo getById(@PathVariable("id") Long id)
    {
        RestaurantInfo restaurantInfo = restaurantInfoService.selectRestaurantInfoById(id);
        return restaurantInfo;
    }

    /**
     * 修改保存餐饮信息：记录餐厅及其食品信息
     */
    @RequiresPermissions("system:info:edit")
    @Log(title = "餐饮信息：记录餐厅及其食品信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody RestaurantInfo restaurantInfo)
    {
        return toAjax(restaurantInfoService.updateRestaurantInfo(restaurantInfo));
    }

    /**
     * 删除餐饮信息：记录餐厅及其食品信息
     */
    @RequiresPermissions("system:info:remove")
    @Log(title = "餐饮信息：记录餐厅及其食品信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(restaurantInfoService.deleteRestaurantInfoByIds(ids));
    }
}
